package day10.ObjectStream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        /*
        Student对象，序列化输出，保存到文件
        f6
        OOS -- FOS -- f6
         */
        Student stu = new Student(1000,"张三", "男",18);
        try {
            objectOutputFIle(stu);
            System.out.println("文件传送成功");
        } catch (IOException e) {
            System.out.println("文件传送失败");
            e.printStackTrace();
        }
    }

    private static void objectOutputFIle(Student stu) throws IOException {
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("/Users/hao/Desktop/abc/f6"));
        out.writeObject(stu);
        out.close();
    }
}
